using System;
using System.Data;
using Utils;
using Utils.DatabaseUtils;


namespace DCEdu
{
public class Customers
{ 
	private int iD;
	public int ID
	{
		get { return iD;}
		set { iD = value;}
	}

	private String name;
	public String Name
	{
		get { return name;}
		set { name = value;}
	}

	private String telephone;
	public String Telephone
	{
		get { return telephone;}
		set { telephone = value;}
	}

	private String address;
	public String Address
	{
		get { return address;}
		set { address = value;}
	}

	private String email;
	public String Email
	{
		get { return email;}
		set { email = value;}
	}

	private String person;
	public String Person
	{
		get { return person;}
		set { person = value;}
	}

	public Customers() {}

	public Customers(int iD, String name, String telephone, String address, String email, String person)
	 {
		this.iD = iD;
 		this.name = name;
 		this.telephone = telephone;
 		this.address = address;
 		this.email = email;
 		this.person = person;
 	}

	public int Add(String name, String telephone, String address, String email, String person)
	{
		try
		{
			int result = SqlHelper.ExecuteNonQuery(Common.Conn,"Customers_Add",name,telephone,address,email,person);
			return result;
		}
		catch(Exception e) {return -1; }
	}

	public int Update(int iD, String name, String telephone, String address, String email, String person)
	{
		try
		{
            int result = SqlHelper.ExecuteNonQuery(Common.Conn, "Customers_Update", iD, name, telephone, address, email, person);
			return result;
		}
		catch(Exception e) {return -1; }
	}

	public int Delete(int iD)
	{
		try
		{
			int result = SqlHelper.ExecuteNonQuery(Common.Conn,"Customers_Delete",iD);
			return result;
		}
		catch(Exception e) {return -1; }
	}

	public int DeleteAll()
	{
		try
		{
			int result = SqlHelper.ExecuteNonQuery(Common.Conn,"Customers_DeleteAll");
			return result;
		}
		catch(Exception e) {return -1; }
	}

	public DataSet Get(int iD)
	{
		try
		{
			DataSet result = SqlHelper.ExecuteDataset(Common.Conn,"Customers_Get",iD);
			return result;
		}
		catch(Exception e) {return null; }
	}

	public DataSet GetAll()
	{
		try
		{
			DataSet result = SqlHelper.ExecuteDataset(Common.Conn,"Customers_GetAll");
			return result;
		}
		catch(Exception e) {return null; }
	}

    public string GenID(string temp, string id)
    {
        int sublength = temp.Length - id.Length;
        temp = temp.Substring(1, sublength) + id;
        return temp;
    }

} 
}
